#include "RedoProcess.h"

RedoProcess::RedoProcess(string cmdString,allTaskList *givenLists,allCommandStack *givenStacks,int time):UndoProcess(cmdString,givenLists,givenStacks,time){
	needCommandStack=&prevCmds->getExecutedCmds();
}

void RedoProcess::HandleProcesss(){
	CommandPackage prevPackage;

	if (canRestore())
		for (int i=0;i<times;i++){
			do {
				prevPackage=getNearestPackage();
				RestoreCommand(prevPackage);
				backUpToUndo(prevPackage);
			}
			while(prevPackage.StillNeedProcess()==true);
		}
	fromNeedtoDisplay();
}

void RedoProcess::backUpToUndo(CommandPackage currentPackage){
	CommandPackage redoPackage=convertToRedoPackage(currentPackage);
	prevCmds->getUndoCmds().push(redoPackage);
}